Skip to content

Conversation

@doytch
Copy link

@doytch doytch commented Sep 21, 2023

Extended the type of the useModalOverlay() props from useOverlay()'s props.

I want to be able to pass shouldCloseOnInteractOutside to useModalOverlay so that I can prevent closing in certain cases.

The values are already being passed through to useOverlay() so I went ahead and simply extended AriaOverlayProps instead of adding more and more repeating variables. I'm not sure if there's a particular reason that approach wasn't taken already, so feel free to recommend the alternative.

It seems like any docs for this should be updated automatically but lemme know if I'm missing anything here.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

Add extra types from useOverlay props
@doytch doytch changed the title Update useModalOverlay.ts Update useModalOverlay types Sep 21, 2023
@doytch doytch closed this Sep 22, 2023
@doytch doytch reopened this Sep 22, 2023
@doytch doytch closed this Sep 22, 2023
@doytch doytch reopened this Sep 22, 2023
@doytch doytch closed this Sep 22, 2023
@doytch doytch reopened this Sep 22, 2023
@doytch
Copy link
Author

doytch commented Sep 22, 2023

Sorry for the close/re-open spam - was trying to shake the CLABot out of its slumber 😆

@LFDanLu
Copy link
Member

LFDanLu commented Sep 22, 2023

I've actually had to do something similar when implementing SubMenus for usePopover, will let you know what the team decides about exposing shouldCloseOnInteractOutside.

@doytch
Copy link
Author

doytch commented Sep 22, 2023

Right on, thanks.

In case it's useful, the specific use case here came up when with our design system's Dialog component. When a Dialog contained a legacy Select component, attempting to select an entry from the dropdown would close the dialog.

useInteractOutside triggers the closing, since the select component would render the dropdown in a React-Portal-based overlay, which is "outside" of the dialog.

*/
isKeyboardDismissDisabled?: boolean
}
export interface AriaModalOverlayProps extends AriaOverlayProps {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed adding shouldCloseOnInteractOutside to usePopover for submenus today, leaning towards being fine adding it there and for useModalOverlay as well as you've done here. I'd personally would prefer just adding shouldCloseOnInteractOutside only here instead of all the overlay props until we get use cases for the rest of those props but happy for the rest of the team to weigh in.

Would you mind adding a basic test for this? You can probably add a new test file for useModalOverlay or for the RAC Modal since it extends from AriaModalOverlayProps. https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/overlays/test/useModal.test.js or any of the tests in https://github.com/adobe/react-spectrum/tree/main/packages/react-aria-components/test could serve as a guide

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review and sorry for the delay, we had an onsite at work which naturally took all my attention last week.

Good to hear - I'll look to hack together a test this week.

@snowystinger snowystinger added the waiting Waiting on Issue Author label Oct 12, 2023
@devongovett devongovett force-pushed the main branch 2 times, most recently from 8cb1a5d to 3013156 Compare July 23, 2024 22:43
@devongovett devongovett force-pushed the main branch 2 times, most recently from a79adcf to 3013156 Compare September 30, 2024 21:00
@LFDanLu
Copy link
Member

LFDanLu commented Apr 12, 2025

This is now supported via #5986.

@LFDanLu LFDanLu closed this Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting Waiting on Issue Author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants